//
// Created by PC on 2024/5/14.
// 高精度除法 高精度/高精度
// http://ybt.ssoier.cn:8088/problem_show.php?pid=1308  pass
// https://oj.youdao.com/problem/9327?from=problems 通过
// https://oj.czos.cn/p/1604 通过
// https://blog.csdn.net/justidle/article/details/104431257
// https://www.bilibili.com/video/BV1ZT4y1q7HD/?spm_id_from=333.337.search-card.all.click&vd_source=f69fe937b6744667b35fadd0fa06ddd2


#include <iostream>

using namespace std;


// x>y:1,x<y:-1,x==y:0
int compare(string x, string y)
{
    if (x.size() > y.size()) return 1;
    if (x.size() < y.size()) return -1;
//    for (int i = x.size() - 1; i >= 0; --i)
    for (int i = 0; i < x.size(); ++i)
    {
        if (x[i] > y[i]) return 1;
        if (x[i] < y[i]) return -1;
    }
    return 0;
}

// 保证x>y的前提下 求x-y
string subtract(string x, string y)
{
    string ans;
    while (x.size() > y.size())
        y = "0" + y;
    int ret[x.size()] = {0};
    for (int i = 0; i < x.size(); ++i)
        ret[i] = x[i] - y[i];
    for (int i = x.size() - 1; i >= 0; --i)
    {
        if (ret[i] < 0)
        {
            ret[i] += 10;
            ret[i - 1] -= 1;
        }
    }
    int i = 0;
    for (; i < x.size(); ++i)
        if (ret[i] != 0) break;
    for (; i < x.size(); ++i)
        ans += (ret[i] + '0');
//    cout<<ans;
    return ans;
}

int main()
{
    // ret=a/b
    string ret;
    string a = "300", b = "299";
//    a = "3", b = "4";
//    a = "5", b = "4";
    a = "1234", b = "12";// 102
    a = "144", b = "12";//
//    a = "3141592", b = "4";  // 785398
//    a = "3141592", b = "785398";  // 4
//    a= "12345678", b= "999"; // 12358
//    a= "123456789123", b= "99999"; // 1234580
//    cin>>a>>b;
//    cout << compare(a, b) << endl;
    if (a == "0" || compare(a,b)==-1)
    {
        cout << 0;
        return 0;
    }

    string t;
    for (int i = 0; i < a.size(); ++i)
    {
        t = t + a[i]; // 当前试商的被除数
        int cur = 0;  // 记录当前的商
        // 如果减之后正好等于零
        if (compare(t, b) == 0)
        {
            cur = 1;
            t = "";
        } else if (compare(t, b) == -1)
        {
//            t+=a[i];
            cur = 0;
        } else
        {
            // 还够减的情况下
            while (compare(t, b) >= 0)
            {
                cur++;
                t = subtract(t, b);
            }
        }
        ret += to_string(cur);
    }
    int i=0;
    // 打印商(去掉前边的零)
    for (; i < ret.size(); ++i)
        if (ret[i]!='0')
            break;
    for (; i < ret.size(); ++i)
        cout<<ret[i];
    // 打印余数
    t= t==""?"0":t;
//    cout<<' '<<t<<endl;
    cout<<endl<<t<<endl;
    return 0;
}